<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}资讯聚合平台{% endblock %}</title>
    <style>
        :root {
            --primary-green: #5a9f73; /* 用户指定的绿色 */
            --secondary-green: #78c08d; /* 用户指定的绿色 */
            --accent-yellow: #F5D544;
            --dark-gray: #2f4b3c; /* 更深的绿色调 */
            --light-gray: #f5f9fc; /* 浅色背景 */
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            margin: 0;
            padding: 0;
            background: linear-gradient(160deg, #f0f7ee 0%, #e6f3e7 100%); /* 绿色小清新背景 */
            color: var(--dark-gray);
            display: flex;
            min-height: 100vh;
            background-attachment: fixed; /* 背景固定 */
        }

        /* 左侧菜单栏样式 */
        .sidebar {
            width: 250px;
            background: rgba(255, 255, 255, 0.2);
            backdrop-filter: blur(10px);
            border-right: 1px solid rgba(255, 255, 255, 0.18);
            padding: 20px 0;
            box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
            display: flex;
            flex-direction: column;
            z-index: 10;
        }

        .sidebar-header {
            padding: 0 20px 20px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.3);
            margin-bottom: 20px;
        }

        .sidebar-header h2 {
            color: var(--dark-gray);
            margin: 0;
            font-size: 1.5em;
        }

        .menu-items {
            list-style: none;
            padding: 0;
            margin: 0;
        }

        .menu-item {
            padding: 15px 20px;
            cursor: pointer;
            transition: all 0.3s;
            border-radius: 0 20px 20px 0;
            margin: 5px 0;
            display: flex;
            align-items: center;
        }

        .menu-item.active {
            background: linear-gradient(135deg, var(--primary-green), var(--secondary-green));
            color: white;
            box-shadow: 0 4px 15px rgba(126, 211, 33, 0.4);
        }

        .menu-item:hover:not(.active) {
            background: rgba(255, 255, 255, 0.3);
        }

        .menu-item i {
            margin-right: 10px;
            font-size: 1.2em;
        }

        .menu-item span {
            font-weight: 500;
        }

        /* 主内容区域样式 */
        .main-content {
            flex: 1;
            padding: 30px;
            overflow-y: auto;
        }

        .content-container {
            background: rgba(255, 255, 255, 0.7); /* 磨玻璃效果，略透明 */
            backdrop-filter: blur(15px); /* 更强的磨玻璃效果 */
            border-radius: 25px;
            padding: 30px;
            box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1); /* 更强的阴影 */
            border: none; /* 移除边框 */
            min-height: calc(100vh - 120px);
        }

        .page-header {
            margin-bottom: 30px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .page-header h1 {
            color: var(--dark-gray);
            margin: 0;
            font-size: 2em;
            font-weight: 600;
        }

        /* 按钮样式 */
        .btn {
            background: linear-gradient(135deg, var(--primary-green), var(--secondary-green));
            color: white;
            padding: 10px 20px;
            border: none;
            border-radius: 20px;
            font-size: 1em;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 4px 10px rgba(90, 159, 115, 0.3); /* 绿色阴影 */
            text-decoration: none;
            display: inline-flex;
            align-items: center;
        }

        .btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 15px rgba(90, 159, 115, 0.5); /* 绿色阴影 */
        }

        .btn i {
            margin-right: 8px;
        }

        /* 消息提示样式 */
        .messages {
            list-style: none;
            padding: 0;
            margin-bottom: 20px;
        }

        .messages li {
            padding: 10px 15px;
            margin-bottom: 10px;
            border-radius: 10px;
            background: rgba(255, 255, 255, 0.5);
        }

        .messages li.success {
            background: rgba(90, 159, 115, 0.2); /* 绿色 */
            color: #2f4b3c;
        }

        .messages li.error {
            background: rgba(255, 99, 71, 0.2);
            color: #8B0000;
        }

        /* 用户信息样式 */
        .user-info {
            display: flex;
            align-items: center;
            margin-top: auto;
            padding: 15px 20px;
            border-top: 1px solid rgba(255, 255, 255, 0.3);
        }

        .user-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background: linear-gradient(135deg, var(--primary-green), var(--secondary-green));
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-weight: bold;
            margin-right: 10px;
            box-shadow: 0 2px 8px rgba(90, 159, 115, 0.3); /* 绿色阴影 */
        }

        .user-details {
            flex: 1;
        }

        .user-name {
            font-weight: 600;
            color: var(--dark-gray);
        }

        .user-role {
            font-size: 0.8em;
            color: #7a938b;
        }

        .logout-btn {
            color: #7a938b;
            background: none;
            border: none;
            cursor: pointer;
            font-size: 1.2em;
            transition: color 0.3s;
        }

        .logout-btn:hover {
            color: var(--dark-gray);
        }
    </style>
    <!-- 引入字体图标 -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
    {% block extra_css %}{% endblock %}
</head>
<body>
    <!-- 左侧菜单栏 -->
    <div class="sidebar">
        <div class="sidebar-header">
            <h2>资讯聚合平台</h2>
        </div>
        <ul class="menu-items">
            <li class="menu-item {% if active_menu == 'ai_config' %}active{% endif %}">
                <a href="{% url 'ai_config' %}" style="text-decoration: none; color: inherit; display: flex; align-items: center; width: 100%;">
                    <i class="fas fa-cog"></i>
                    <span>AI服务配置</span>
                </a>
            </li>
            <li class="menu-item {% if active_menu == 'push_config' %}active{% endif %}">
                <a href="{% url 'push_config' %}" style="text-decoration: none; color: inherit; display: flex; align-items: center; width: 100%;">
                    <i class="fas fa-paper-plane"></i>
                    <span>推送项目配置</span>
                </a>
            </li>
            <li class="menu-item {% if active_menu == 'keywords' %}active{% endif %}">
                <a href="{% url 'keywords' %}" style="text-decoration: none; color: inherit; display: flex; align-items: center; width: 100%;">
                    <i class="fas fa-key"></i>
                    <span>推送关键词管理</span>
                </a>
            </li>
            <li class="menu-item {% if active_menu == 'push_tasks' %}active{% endif %}">
                <a href="{% url 'push_tasks' %}" style="text-decoration: none; color: inherit; display: flex; align-items: center; width: 100%;">
                    <i class="fas fa-tasks"></i>
                    <span>推送执行列表</span>
                </a>
            </li>
        </ul>
        <div class="user-info">
            <div class="user-avatar">
                {{ request.user.username|first|upper }}
            </div>
            <div class="user-details">
                <div class="user-name">{{ request.user.username }}</div>
                <div class="user-role">管理员</div>
            </div>
            <a href="{% url 'logout' %}" class="logout-btn" title="退出登录">
                <i class="fas fa-sign-out-alt"></i>
            </a>
        </div>
    </div>

    <!-- 主内容区域 -->
    <div class="main-content">
        <div class="content-container">
            {% if messages %}
                <ul class="messages">
                    {% for message in messages %}
                        <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
                    {% endfor %}
                </ul>
            {% endif %}
            
            <div class="page-header">
                <h1>{% block page_title %}{% endblock %}</h1>
                {% block page_actions %}{% endblock %}
            </div>
            
            {% block content %}{% endblock %}
        </div>
    </div>

    {% block extra_js %}{% endblock %}
</body>
</html>